import React from 'react';
import { LegionsProModal,LegionsStore } from 'legions-pro-design'
import { OpenConfirm } from 'legions-lunar/antd-toolkit';
import { Button,message } from 'antd';
import ProjectQueryPropertyStore from '../../stores/projectQueryProperty';
import TableQueryParamsProperty from '../components.property/tableQueryParamsProperty';
import { PropertyQueryFormFields } from '../../models/form/propertyQueryFormFields';
/** 搜索条件属性设置对话框组件 */
export const QueryParmsPropertyModal = () => {
    const QueryPropertyApp = LegionsStore.get(ProjectQueryPropertyStore)
    return <LegionsProModal
        closable={false}
        maskClosable={false}
        footer={(<React.Fragment>
            <Button onClick={() => {
                OpenConfirm({
                    title: '关闭',
                    content: '部分数据未保存,如果离开数据将无法保存,您确定离开吗？',
                    onOk: () => {
                        QueryPropertyApp.queryPropertyModalRef.viewModel.visible = false;
                    }
                })
            }}>取消</Button>
            <Button type="primary" onClick={() => {
                QueryPropertyApp.queryConditionsFormProperyRef.viewModel.form.validateFields((error,values) => {
                    const value = QueryPropertyApp.queryConditionsFormProperyRef.viewModel.InputDataModel as PropertyQueryFormFields
                    if (!error) {
                        QueryPropertyApp.queryPropertyModalRef.viewModel.visible = false;
                        message.success('属性设置成功')
                    }
                })
            }}>保存</Button>
        </React.Fragment>)}
        modalType="drawer"
        placement="right"
        onReady={(value) => {
            QueryPropertyApp.queryPropertyModalRef = value;
            const width = 450;
            QueryPropertyApp.queryPropertyModalRef.viewModel.width = width;
        }}>
        <TableQueryParamsProperty ></TableQueryParamsProperty>
    </LegionsProModal>
}